package com.wxg.util;

import org.junit.Ignore;
import org.junit.Test;

public class WinProcessUtilsTest {

	@Test
	@Ignore
	public void getWinPidTest(){
		String pid = WinProcessUtils.getWinPid(5000);
		System.out.printf( "pid : %s\n", pid );
	}
	
	
	/**
	 * 
C:\Users\wxg>netstat -aon | findstr "5000"
  TCP    0.0.0.0:5000           0.0.0.0:0              LISTENING       14480
  TCP    127.0.0.1:5000         127.0.0.1:56546        ESTABLISHED     14480
  TCP    127.0.0.1:5000         127.0.0.1:56547        ESTABLISHED     14480
  TCP    127.0.0.1:5000         127.0.0.1:56548        ESTABLISHED     14480
  TCP    127.0.0.1:5000         127.0.0.1:56549        ESTABLISHED     14480
  TCP    127.0.0.1:5000         127.0.0.1:56550        ESTABLISHED     14480
  TCP    127.0.0.1:5000         127.0.0.1:56551        ESTABLISHED     14480
  TCP    127.0.0.1:50000        0.0.0.0:0              LISTENING       20792
  TCP    127.0.0.1:56502        127.0.0.1:5000         TIME_WAIT       0
  TCP    127.0.0.1:56546        127.0.0.1:5000         ESTABLISHED     10508
  TCP    127.0.0.1:56547        127.0.0.1:5000         ESTABLISHED     10508
  TCP    127.0.0.1:56548        127.0.0.1:5000         ESTABLISHED     10508
  TCP    127.0.0.1:56549        127.0.0.1:5000         ESTABLISHED     10508
  TCP    127.0.0.1:56550        127.0.0.1:5000         ESTABLISHED     10508
  TCP    127.0.0.1:56551        127.0.0.1:5000         ESTABLISHED     10508
	 * 
	 * 
C:\Users\wxg>netstat -aon | findstr "5000"
  TCP    0.0.0.0:5000           0.0.0.0:0              LISTENING       14480
  TCP    127.0.0.1:50000        0.0.0.0:0              LISTENING       20792
  TCP    127.0.0.1:56546        127.0.0.1:5000         TIME_WAIT       0
  TCP    127.0.0.1:56547        127.0.0.1:5000         TIME_WAIT       0
  TCP    127.0.0.1:56548        127.0.0.1:5000         TIME_WAIT       0
  TCP    127.0.0.1:56549        127.0.0.1:5000         TIME_WAIT       0
  TCP    127.0.0.1:56550        127.0.0.1:5000         TIME_WAIT       0
  TCP    127.0.0.1:56551        127.0.0.1:5000         TIME_WAIT       0
	 * 
	 */
	@Test
	public void killWinProcessTest(){
		WinProcessUtils.killWinProcess(WinProcessUtils.getWinPid(5000));
	}
}
